<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>创建及其下载二进制文件</title>
</head>
<body>
	<script>
		function Blob_test() {
			var text = document.getElementById("text").value;
			var blob;
			var result = document.getElementById("result");
			if(!window.Blob) {
				result.innerHTML = "不支持Blob";
			} else {
				blob = new Blob([text]);
				if(window.URL) {
					result.innerHTML = "<a download href = "+window.URL.createObjectURL(blob)+" target='_blank'>文件下载</a>"
				}
			}
		}
	</script>
	<textarea name="" id="text" cols="30" rows="10"></textarea>
	<button onclick="Blob_test()">创建及下载二进制文件</button>
	<output id="result"></output>
</body>
</html>